import config from '@/config'

/**
 * 返回回调地址
 */
export function getCallBack (){
  // We can't use window.location.hash here because it's not
  // consistent across browsers - Firefox will pre-decode it!
  let href = window.location.href
  const searchIndex = href.indexOf('?')
  if (searchIndex < 0) {
    return config.HOME
  } else {
    let redirectURL = href.slice(searchIndex+1);
    let redirectStr = 'redirect_uri';
    let redirectIndex = redirectURL.indexOf(redirectStr)
    if(redirectIndex<0){
      return config.HOME
    }
    href = redirectURL.slice(redirectIndex+redirectStr.length+1)
    href = decodeURIComponent(href)
  }
  return href
}